<?php
include_once 'mod.php';
$mod = new mod();
if($_SERVER['REQUEST_METHOD']=='POST'){
    $name = $_POST['name'];
    $login = $_POST['login'];
    $pwd =$_POST['pwd'];
    if (empty($login)){
        die('用户名为空<a href="register.php.php">重新注册</a>');
    }
    if (empty($pwd)){
        die('密码为空<a href="register.php.php">重新注册</a>');
    }
    if (empty($name)){
        die('姓名为空<a href="register.php.php">重新注册</a>');
    }
    /////////////////////////////////////

    $mysql = $mod->link();


    $up = $mod->UP();
    $sql = "insert into user (`name`,`login`,`password`,`img`) values ('$name','$login',$pwd,'$up')";
    $result = $mod->IDU($mysql,$sql);
    if ($result && $up){
        die('注册成功<a href="login.php">前往登录</a>');
    }else{
        die('注册失败<a href="register.php">重新注册</a>');
    }

}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>注册</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
    <p>用户:<input type="text" name="name"></p>
    <p>头像:<input type="file" name="file"></p>
    <p>用户名:<input type="text" name="login"></p>
    <p>密码:<input type="password" name="pwd"></p>
    <input type="submit" value="注册">
</form>
</body>
</html>
